@file:Suppress("UNCHECKED_CAST", "USELESS_CAST", "INAPPLICABLE_JVM_NAME", "UNUSED_ANONYMOUS_PARAMETER", "NAME_SHADOWING", "UNNECESSARY_NOT_NULL_ASSERTION")
package uni.UNIF42C880
import io.dcloud.uniapp.*
import io.dcloud.uniapp.extapi.*
import io.dcloud.uniapp.framework.*
import io.dcloud.uniapp.runtime.*
import io.dcloud.uniapp.vue.*
import io.dcloud.uniapp.vue.shared.*
import io.dcloud.uts.*
import io.dcloud.uts.Map
import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import io.dcloud.uniapp.extapi.getStorageSync as uni_getStorageSync
import io.dcloud.uniapp.extapi.hideLoading as uni_hideLoading
import io.dcloud.uniapp.extapi.setStorageSync as uni_setStorageSync
import io.dcloud.uniapp.extapi.showLoading as uni_showLoading
import io.dcloud.uniapp.extapi.showToast as uni_showToast
open class GenPagesSettingsSettings : BasePage {
    constructor(__ins: ComponentInternalInstance, __renderer: String?) : super(__ins, __renderer) {
        onLoad(fun(_: OnLoadOptions) {
            this.loadSettings()
        }
        , __ins)
    }
    @Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
    override fun `$render`(): Any? {
        val _ctx = this
        val _cache = this.`$`.renderCache
        val _component_switch = resolveComponent("switch")
        val _component_transition = resolveComponent("transition")
        val _component_picker = resolveComponent("picker")
        return createElementVNode("view", utsMapOf("class" to "settings-container"), utsArrayOf(
            createElementVNode("scroll-view", utsMapOf("scroll-y" to "true", "class" to "settings-scroll"), utsArrayOf(
                createElementVNode("view", utsMapOf("class" to "settings-list"), utsArrayOf(
                    createElementVNode("view", utsMapOf("class" to "settings-group"), utsArrayOf(
                        createElementVNode("view", utsMapOf("class" to "settings-header"), utsArrayOf(
                            createElementVNode("text", utsMapOf("class" to "settings-title"), "使用VPN服务器"),
                            createVNode(_component_switch, utsMapOf("checked" to _ctx.useProxyServer, "onChange" to _ctx.onUsePorxyServer, "color" to "#007AFF"), null, 8, utsArrayOf(
                                "checked",
                                "onChange"
                            ))
                        )),
                        createVNode(_component_transition, utsMapOf("name" to "slide-fade"), utsMapOf("default" to withSlotCtx(fun(): UTSArray<Any> {
                            return utsArrayOf(
                                withDirectives(createElementVNode("view", utsMapOf("class" to "proxy-settings"), utsArrayOf(
                                    createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                                        createElementVNode("text", utsMapOf("class" to "item-label"), "VPN服务器地址"),
                                        createElementVNode("input", utsMapOf("type" to "text", "class" to "item-input", "modelValue" to _ctx.proxyServerAddress, "onInput" to fun(`$event`: InputEvent){
                                            _ctx.proxyServerAddress = `$event`.detail.value
                                        }
                                        , "disabled" to !_ctx.useProxyServer, "placeholder" to "填入域名或IP地址"), null, 40, utsArrayOf(
                                            "modelValue",
                                            "onInput",
                                            "disabled"
                                        ))
                                    )),
                                    createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                                        createElementVNode("text", utsMapOf("class" to "item-label"), "用户名"),
                                        createElementVNode("input", utsMapOf("type" to "text", "class" to "item-input", "modelValue" to _ctx.proxyServerUsername, "onInput" to fun(`$event`: InputEvent){
                                            _ctx.proxyServerUsername = `$event`.detail.value
                                        }
                                        , "disabled" to !_ctx.useProxyServer, "placeholder" to "用户名"), null, 40, utsArrayOf(
                                            "modelValue",
                                            "onInput",
                                            "disabled"
                                        ))
                                    )),
                                    createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                                        createElementVNode("text", utsMapOf("class" to "item-label"), "密码"),
                                        createElementVNode("input", utsMapOf("type" to "password", "class" to "item-input", "modelValue" to _ctx.proxyServerPassword, "onInput" to fun(`$event`: InputEvent){
                                            _ctx.proxyServerPassword = `$event`.detail.value
                                        }
                                        , "disabled" to !_ctx.useProxyServer, "placeholder" to "******"), null, 40, utsArrayOf(
                                            "modelValue",
                                            "onInput",
                                            "disabled"
                                        ))
                                    )),
                                    createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                                        createElementVNode("button", utsMapOf("class" to "test-btn", "onClick" to _ctx.testVPNConnection), "测试VPN", 8, utsArrayOf(
                                            "onClick"
                                        ))
                                    ))
                                ), 512), utsArrayOf(
                                    utsArrayOf(
                                        vShow,
                                        _ctx.useProxyServer
                                    )
                                ))
                            )
                        }
                        ), "_" to 1))
                    )),
                    createElementVNode("view", utsMapOf("class" to "settings-group"), utsArrayOf(
                        createElementVNode("view", utsMapOf("class" to "settings-header"), utsArrayOf(
                            createElementVNode("text", utsMapOf("class" to "settings-title"), "服务器设置"),
                            createElementVNode("button", utsMapOf("class" to "test-btn", "onClick" to _ctx.testConnection), "测试连接", 8, utsArrayOf(
                                "onClick"
                            ))
                        )),
                        createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                            createElementVNode("text", utsMapOf("class" to "item-label"), "ComfyUI服务器地址"),
                            createElementVNode("input", utsMapOf("type" to "text", "class" to "item-input", "modelValue" to _ctx.serverAddress, "onInput" to fun(`$event`: InputEvent){
                                _ctx.serverAddress = `$event`.detail.value
                            }
                            , "placeholder" to "例如: http://127.0.0.1:8188"), null, 40, utsArrayOf(
                                "modelValue",
                                "onInput"
                            ))
                        )),
                        createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                            createElementVNode("text", utsMapOf("class" to "item-label"), "连接状态"),
                            createElementVNode("view", utsMapOf("class" to "connection-status"), utsArrayOf(
                                createElementVNode("view", utsMapOf("class" to normalizeClass(utsArrayOf(
                                    "status-indicator",
                                    utsMapOf("connected" to _ctx.isConnected)
                                ))), null, 2),
                                createElementVNode("text", utsMapOf("class" to "status-text"), toDisplayString(if (_ctx.isConnected) {
                                    "已连接"
                                } else {
                                    "未连接"
                                }
                                ), 1)
                            ))
                        )),
                        createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                            createElementVNode("text", utsMapOf("class" to "item-label"), "设备名称"),
                            createElementVNode("view", utsMapOf("class" to "connection-status"), utsArrayOf(
                                createElementVNode("text", utsMapOf("class" to "status-text"), toDisplayString(_ctx.deviceName), 1)
                            ))
                        )),
                        createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                            createElementVNode("text", utsMapOf("class" to "item-label"), "系统版本"),
                            createElementVNode("view", utsMapOf("class" to "connection-status"), utsArrayOf(
                                createElementVNode("text", utsMapOf("class" to "status-text"), toDisplayString(_ctx.softwareVersion), 1)
                            ))
                        ))
                    ))
                )),
                createElementVNode("view", utsMapOf("class" to "settings-group"), utsArrayOf(
                    createElementVNode("view", utsMapOf("class" to "settings-header"), utsArrayOf(
                        createElementVNode("text", utsMapOf("class" to "settings-title"), "图片设置")
                    )),
                    createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                        createElementVNode("text", utsMapOf("class" to "item-label"), "默认图片质量"),
                        createVNode(_component_picker, utsMapOf("range" to _ctx.imageQualityOptions, "value" to _ctx.imageQualityIndex, "onChange" to _ctx.onImageQualityChange, "class" to "picker"), utsMapOf("default" to withSlotCtx(fun(): UTSArray<Any> {
                            return utsArrayOf(
                                createElementVNode("view", utsMapOf("class" to "picker-text"), utsArrayOf(
                                    createElementVNode("text", null, toDisplayString(_ctx.imageQualityOptions[_ctx.imageQualityIndex]), 1)
                                ))
                            )
                        }
                        ), "_" to 1), 8, utsArrayOf(
                            "range",
                            "value",
                            "onChange"
                        ))
                    )),
                    createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                        createElementVNode("text", utsMapOf("class" to "item-label"), "自动保存生成结果"),
                        createVNode(_component_switch, utsMapOf("checked" to _ctx.autoSave, "onChange" to _ctx.onAutoSaveChange, "color" to "#007AFF"), null, 8, utsArrayOf(
                            "checked",
                            "onChange"
                        ))
                    ))
                )),
                createElementVNode("view", utsMapOf("class" to "settings-group"), utsArrayOf(
                    createElementVNode("view", utsMapOf("class" to "settings-header"), utsArrayOf(
                        createElementVNode("text", utsMapOf("class" to "settings-title"), "关于应用")
                    )),
                    createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                        createElementVNode("text", utsMapOf("class" to "item-label"), "版本"),
                        createElementVNode("text", utsMapOf("class" to "item-value"), "1.0.0")
                    )),
                    createElementVNode("view", utsMapOf("class" to "settings-item"), utsArrayOf(
                        createElementVNode("text", utsMapOf("class" to "item-label"), "开发者"),
                        createElementVNode("text", utsMapOf("class" to "item-value"), "AI实践项目团队")
                    ))
                ))
            )),
            createElementVNode("view", utsMapOf("class" to "save-btn-container"), utsArrayOf(
                createElementVNode("button", utsMapOf("class" to "save-btn", "onClick" to _ctx.saveSettings), "保存设置", 8, utsArrayOf(
                    "onClick"
                ))
            ))
        ))
    }
    open var useProxyServer: Boolean by `$data`
    open var proxyServerAddress: String by `$data`
    open var proxyServerUsername: String by `$data`
    open var proxyServerPassword: String by `$data`
    open var serverAddress: String by `$data`
    open var isConnected: Boolean by `$data`
    open var deviceName: String by `$data`
    open var softwareVersion: String by `$data`
    open var imageQualityOptions: UTSArray<String> by `$data`
    open var imageQualityIndex: Number by `$data`
    open var autoSave: Boolean by `$data`
    @Suppress("USELESS_CAST")
    override fun data(): Map<String, Any?> {
        return utsMapOf("useProxyServer" to false, "proxyServerAddress" to "", "proxyServerUsername" to "", "proxyServerPassword" to "", "serverAddress" to "http://127.0.0.1:8188", "isConnected" to false, "deviceName" to "-", "softwareVersion" to "-", "imageQualityOptions" to utsArrayOf(
            "低",
            "中",
            "高"
        ), "imageQualityIndex" to 1, "autoSave" to true)
    }
    open var loadSettings = ::gen_loadSettings_fn
    open fun gen_loadSettings_fn() {
        try {
            val settings = uni_getStorageSync("appSettings")
            val parsedSettings = settings as ComfySetting
            this.useProxyServer = parsedSettings.useProxyServer || this.useProxyServer
            this.proxyServerAddress = parsedSettings.proxyServerAddress
            this.proxyServerUsername = parsedSettings.proxyServerUsername
            this.proxyServerPassword = parsedSettings.proxyServerPassword
            this.serverAddress = parsedSettings.serverAddress
            this.imageQualityIndex = parsedSettings.imageQualityIndex
            this.autoSave = parsedSettings.autoSave
        }
         catch (e: Throwable) {
            console.error("加载设置失败:", e)
        }
    }
    open var saveSettings = ::gen_saveSettings_fn
    open fun gen_saveSettings_fn() {
        try {
            val settings = ComfySetting(useProxyServer = this.useProxyServer, proxyServerAddress = this.proxyServerAddress, proxyServerUsername = this.proxyServerUsername, proxyServerPassword = this.proxyServerPassword, serverAddress = this.serverAddress, imageQualityIndex = this.imageQualityIndex, autoSave = this.autoSave)
            uni_setStorageSync("appSettings", settings)
            uni_showToast(ShowToastOptions(title = "设置已保存", icon = "success"))
        }
         catch (e: Throwable) {
            console.error("保存设置失败:", e)
            uni_showToast(ShowToastOptions(title = "保存设置失败", icon = "none"))
        }
    }
    open var testConnection = ::gen_testConnection_fn
    open fun gen_testConnection_fn() {
        uni_showLoading(ShowLoadingOptions(title = "正在连接..."))
    }
    open var testVPNConnection = ::gen_testVPNConnection_fn
    open fun gen_testVPNConnection_fn() {
        uni_showLoading(ShowLoadingOptions(title = "功能暂未开放..."))
        setTimeout(fun(){
            uni_hideLoading()
        }
        , 1500)
    }
    open var onImageQualityChange = ::gen_onImageQualityChange_fn
    open fun gen_onImageQualityChange_fn(e: Any) {
        console.log(e)
    }
    open var onAutoSaveChange = ::gen_onAutoSaveChange_fn
    open fun gen_onAutoSaveChange_fn(e: Any) {}
    open var onUsePorxyServer = ::gen_onUsePorxyServer_fn
    open fun gen_onUsePorxyServer_fn(e: Any) {}
    companion object {
        val styles: Map<String, Map<String, Map<String, Any>>> by lazy {
            normalizeCssStyles(utsArrayOf(
                styles0
            ), utsArrayOf(
                GenApp.styles
            ))
        }
        val styles0: Map<String, Map<String, Map<String, Any>>>
            get() {
                return utsMapOf("settings-container" to padStyleMapOf(utsMapOf("backgroundColor" to "#f5f5f5", "height" to "100%", "display" to "flex", "flexDirection" to "column")), "settings-scroll" to padStyleMapOf(utsMapOf("width" to "100%", "flex" to 1, "display" to "flex")), "settings-list" to padStyleMapOf(utsMapOf("paddingTop" to 15, "paddingRight" to 15, "paddingBottom" to 15, "paddingLeft" to 15)), "settings-group" to padStyleMapOf(utsMapOf("display" to "flex", "flexDirection" to "column", "backgroundColor" to "#ffffff", "borderTopLeftRadius" to 10, "borderTopRightRadius" to 10, "borderBottomRightRadius" to 10, "borderBottomLeftRadius" to 10, "marginBottom" to 20, "overflow" to "hidden")), "settings-header" to padStyleMapOf(utsMapOf("paddingTop" to 15, "paddingRight" to 15, "paddingBottom" to 15, "paddingLeft" to 15, "display" to "flex", "flexDirection" to "row", "alignItems" to "center", "justifyContent" to "space-between", "borderBottomWidth" to 1, "borderBottomStyle" to "solid", "borderBottomColor" to "#f0f0f0")), "settings-title" to padStyleMapOf(utsMapOf("fontSize" to 16, "fontWeight" to "bold", "color" to "#333333")), "settings-item" to padStyleMapOf(utsMapOf("paddingTop" to 15, "paddingRight" to 15, "paddingBottom" to 15, "paddingLeft" to 15, "display" to "flex", "flexDirection" to "row", "alignItems" to "center", "justifyContent" to "space-between", "borderBottomWidth" to 1, "borderBottomStyle" to "solid", "borderBottomColor" to "#f0f0f0", "borderBottomWidth:last-child" to "medium", "borderBottomStyle:last-child" to "none", "borderBottomColor:last-child" to "#000000")), "item-label" to padStyleMapOf(utsMapOf("fontSize" to 14, "color" to "#333333")), "item-value" to padStyleMapOf(utsMapOf("fontSize" to 14, "color" to "#666666")), "item-input" to padStyleMapOf(utsMapOf("width" to 200, "height" to 35, "borderTopWidth" to 1, "borderRightWidth" to 1, "borderBottomWidth" to 1, "borderLeftWidth" to 1, "borderTopStyle" to "solid", "borderRightStyle" to "solid", "borderBottomStyle" to "solid", "borderLeftStyle" to "solid", "borderTopColor" to "#dddddd", "borderRightColor" to "#dddddd", "borderBottomColor" to "#dddddd", "borderLeftColor" to "#dddddd", "borderTopLeftRadius" to 5, "borderTopRightRadius" to 5, "borderBottomRightRadius" to 5, "borderBottomLeftRadius" to 5, "paddingTop" to 0, "paddingRight" to 10, "paddingBottom" to 0, "paddingLeft" to 10, "textAlign" to "right", "fontSize" to 14)), "connection-status" to padStyleMapOf(utsMapOf("display" to "flex", "flexDirection" to "row", "alignItems" to "center")), "status-indicator" to utsMapOf("" to utsMapOf("width" to 10, "height" to 10, "borderTopLeftRadius" to 5, "borderTopRightRadius" to 5, "borderBottomRightRadius" to 5, "borderBottomLeftRadius" to 5, "backgroundColor" to "#FF3B30", "marginRight" to 5), ".connected" to utsMapOf("backgroundColor" to "#4CD964")), "status-text" to padStyleMapOf(utsMapOf("fontSize" to 14, "color" to "#666666")), "test-btn" to padStyleMapOf(utsMapOf("width" to "30%", "height" to 36, "backgroundColor" to "#007AFF", "color" to "#ffffff", "borderTopLeftRadius" to 5, "borderTopRightRadius" to 5, "borderBottomRightRadius" to 5, "borderBottomLeftRadius" to 5, "fontSize" to 14)), "picker" to padStyleMapOf(utsMapOf("height" to 35)), "picker-text" to padStyleMapOf(utsMapOf("height" to 35, "lineHeight" to "35px")), "save-btn-container" to padStyleMapOf(utsMapOf("paddingTop" to 15, "paddingRight" to 15, "paddingBottom" to 15, "paddingLeft" to 15)), "save-btn" to padStyleMapOf(utsMapOf("width" to "100%", "height" to 45, "backgroundColor" to "#007AFF", "color" to "#ffffff", "borderTopLeftRadius" to 22.5, "borderTopRightRadius" to 22.5, "borderBottomRightRadius" to 22.5, "borderBottomLeftRadius" to 22.5, "fontSize" to 16, "fontWeight" to "bold")), "proxy-settings" to padStyleMapOf(utsMapOf("overflow" to "hidden")), "slide-fade-enter-active" to padStyleMapOf(utsMapOf("transitionDuration" to "0.2s", "transitionTimingFunction" to "ease")), "slide-fade-leave-active" to padStyleMapOf(utsMapOf("transitionDuration" to "0.2s", "transitionTimingFunction" to "cubic-bezier(1,0.5,0.8,1)")), "slide-fade-enter-from" to padStyleMapOf(utsMapOf("transform" to "translateY(-20px)", "opacity" to 0, "maxHeight" to 0)), "slide-fade-leave-to" to padStyleMapOf(utsMapOf("transform" to "translateY(-20px)", "opacity" to 0, "maxHeight" to 0)), "slide-fade-enter-to" to padStyleMapOf(utsMapOf("transform" to "translateY(0)", "opacity" to 1, "maxHeight" to 300)), "slide-fade-leave-from" to padStyleMapOf(utsMapOf("transform" to "translateY(0)", "opacity" to 1, "maxHeight" to 300)), "@TRANSITION" to utsMapOf("slide-fade-enter-active" to utsMapOf("duration" to "0.2s", "timingFunction" to "ease"), "slide-fade-leave-active" to utsMapOf("duration" to "0.2s", "timingFunction" to "cubic-bezier(1,0.5,0.8,1)")))
            }
        var inheritAttrs = true
        var inject: Map<String, Map<String, Any?>> = utsMapOf()
        var emits: Map<String, Any?> = utsMapOf()
        var props = normalizePropsOptions(utsMapOf())
        var propsNeedCastKeys: UTSArray<String> = utsArrayOf()
        var components: Map<String, CreateVueComponent> = utsMapOf()
    }
}
